home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
687
< prev
next >
Wrap
Text File
|
1996-08-06
|
1KB
|
34 lines
Newsgroups: comp.std.c
Path: blackbush.xlink.net!slsv6bt!news
From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
Subject: Re: Initializing a variable in terms of itself
In-Reply-To: tim@franck's message of 1 Apr 1996 21:53:57 GMT
Message-ID: <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de>
Sender: news@lts.sel.alcatel.de
Organization: GABI Software, Sarl.
References: <4jpj9l$ik9@cnn.Princeton.EDU>
Date: 02 Apr 1996 15:13:23 GMT
In article <4jpj9l$ik9@cnn.Princeton.EDU> tim@franck (Tim Hollebeek)
writes:
|> Just out of curiosity, is this legal?
|> int main() {
|> int x = x;
|> return 0;
|> }
No, it is undefined behavior, because you are accessing a variable
before having initialized it.
The reference to `x' in the initialization expression is not, per se,
illegal. The variable is declared, and available for use, as soon as
the compiler sees the `=' sign.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
-- A la recherche d'une activitΘ dans une region francophone